<?php

namespace services\notices;

use think\Request;
use think\Response;
use think\Session;
use Sanyc\Aliyun\AliyunEmail;
use think\Exception;
use think\Config;

class Mail implements NoticeInterface
{
    private $notice = '';

    public $options = [
        ];

    private $templates = [
        'quit_deposits' => 'FdXX-frnAXM-3L9AaRuYZ6z9rGb9Tlbatwy9c_kPVys',
        'recharge'      => 'qF4scfrnIZ8D6kJ-gTS2oqdCZ95Xk7j16bmZIlmLPjo',
        'ordercreate'   => 'tZ8VLtV5BehUvO58FzqeQj1VYJQAe56HqQESOSAOoQo',
        'wishcreate'    => 'onU0ZmRYGjoyi8IxYFeqWeaY59hpFVVMaA-nICHFfIw'
    ];

	public function __construct($pimple)
    {
        $pimple->mail  = $this;
        $this->options = array_merge($this->options, $pimple->options);
        $this->notice  = AliyunEmail::init($this->options);
    }


    public function send($email, $title, $content = null)
    {
        $this->notice->send($email, $title, $content ? : $title);
        date_default_timezone_set(\think\Config::get('default_timezone'));
    }
}
